﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using YzApi.Toolkit;

namespace YzApi.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    [Route("[controller]")]
    public class CaptchaController : BaseController
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public CaptchaController(DbContext context):base(context)
        {

        }

        /// <summary>
        /// 获取图形验证码（Captcha）的图片，后台会自动将其文本保存在session中
        /// </summary>
        /// <returns>图形验证码（Captcha）的图片</returns>
        [HttpGet]
        [Route(nameof(Get))]
        public FileResult Get()
        {
            string text = Captcha.CreateText();
            return File(Captcha.CreateGraphic(text), @"image/jpeg");
        }
    }
}
